﻿using MyUAMS.BLL;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;

public partial class InsertAsset : System.Web.UI.Page
{
    WorkServer workSrc = new WorkServer();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Panel1.Visible = false;
        }
    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            if (workSrc.IsNameExist(txtName.Text.Trim()))
            {
                txtName.Text = "该名称已注册!";
            }
            else
            {
                workSrc.Insert(txtName.Text.Trim(), AmountUnit.Text.Trim(),AssetDescribe.Text.Trim(), Convert.ToInt32(TypeId.SelectedValue), txtCperson.Text.Trim(), decimal.Parse(txtTelephone.Text.Trim()), txtDpartment.Text.Trim(), decimal.Parse(txtDtelephone.Text.Trim()));
                username.Text = "添加成功";
                Response.Redirect("MyWork.aspx");

            }
        }
    }

    protected void return_Click(object sender, EventArgs e)
    {
        Response.Redirect("MyWork.aspx");
    }

    protected void typebtn_Click(object sender, EventArgs e)
    {
        if (Panel1.Visible)
        {
            Panel1.Visible = false;
            typetxt.Text = ""; 
        }
        else
        {
            Panel1.Visible = true;

            string filePath = @"F:\web系统应用\MyUAMS\MyUAMS2\txtfile\text.txt";

            using (StreamReader reader = new StreamReader(filePath))
            {
                string line;
                typetxt.Text = ""; 
                while ((line = reader.ReadLine()) != null)
                {
                    typetxt.Text += line + "\n";
                }
            }
        }
    }
}